package com.yy.common.commonwidget;

import android.view.View;
import android.widget.AdapterView;

import java.util.Calendar;

/**
 * des:防止重复点击
 */

public abstract class OnNoDoubleItemClickListener implements AdapterView.OnItemClickListener {

    public static final int MIN_CLICK_DELAY_TIME = 1000;
    private long lastClickTime = 0;

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(adapterView,view,i,l);
        }
    }
    protected abstract void onNoDoubleClick(AdapterView<?> adapterView, View view, int i, long l);

}